package led.control.home;

import led.control.home.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.GestureDetector;
import android.view.GestureDetector.OnGestureListener;
import android.view.MotionEvent;
import android.view.animation.AnimationUtils;
import android.widget.ViewFlipper;

public class Test extends Activity implements OnGestureListener{
	/** Called when the activity is first created. */
	private GestureDetector detector;
	private ViewFlipper flipper;
	int i = 0;
	
	
	private CircularSeekBar seekbar;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_activity);
		
		detector = new GestureDetector(this);
		flipper = (ViewFlipper) this.findViewById(R.id.ViewFlipper1);
		
		
		seekbar = (CircularSeekBar) findViewById(R.id.seekbar);
		seekbar.setMaxProgress(360);
		seekbar.setProgress(90);
		
	}
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		// TODO Auto-generated method stub
		return this.detector.onTouchEvent(event); 
	}
	
	@Override
	public boolean onDown(MotionEvent e) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void onShowPress(MotionEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public boolean onSingleTapUp(MotionEvent e) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
			float distanceY) {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public void onLongPress(MotionEvent e) {
		// TODO Auto-generated method stub

	}

	@Override
	public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
			float velocityY) {
		System.out.println("in------------>>>>>>>");
		if (e1.getX() - e2.getX() > 120) {
			if (i < 500) {
				i++;
				this.flipper.setInAnimation(AnimationUtils.loadAnimation(this,
						R.anim.animation_right_in));
				this.flipper.setOutAnimation(AnimationUtils.loadAnimation(this,
						R.anim.animation_left_out));
				this.flipper.showNext();
			}
			return true;
		} 
		else if (e1.getX() - e2.getX() < -120) {
			if (i > 0) {
				i--;
				this.flipper.setInAnimation(AnimationUtils.loadAnimation(this,
						R.anim.animation_left_in));
				this.flipper.setOutAnimation(AnimationUtils.loadAnimation(this,
						R.anim.animation_right_out));
				this.flipper.showPrevious();
			}
			return true;
		}
		return false;
		
	}
	
	
}